<?php

// $Id$


require_once(TANGRA_MAIN_DIR.'core/config_loader_file.class.php');

require_once('mail_smtp_settings.class.php');


class SMTP_Settings_Loader extends Tangra_Class {
	public static function load_smtp_settings($path_to_conf_file) {
		if (!file_exists($path_to_conf_file)) {
			throw new Tangra_Module_Exception('Cannot find: '.$path_to_conf_file);
		}

		$conf_loader = new Config_Loader_File($path_to_conf_file);

		$host = $conf_loader->get_conf_value('SMTP_HOST');
		$port = $conf_loader->get_conf_value('SMTP_PORT');
		$username = $conf_loader->get_conf_value('SMTP_USERNAME');
		$password = $conf_loader->get_conf_value('SMTP_PASSWORD');
		$enc = $conf_loader->get_conf_value('SMTP_ENCRYPTION');
		$timeout = $conf_loader->get_conf_value('SMTP_TIMEOUT');

		if (trim($username)) {
			$use_auth = true;
		} else {
			$use_auth = false;
		}

		$settings = new Mail_SMTP_Settigns($host, $username, $password, $port, $timeout, $use_auth,  $enc);

		return $settings;
	}
}